from Scheduler import Scheduler
from datetime import datetime, timedelta
import sys

# inputs = {"userlist": [{"name": "jess, joseph i"},
# 					{"name": "mcgreevy, sarah"},
# 					{"name": "grimm, michael j"},
# 					{"name": "mcgrath, d kevin"}],
# 		  "window": {"start": "08/05/2014 07:00", "end": "08/05/2014 17:00"}}

inputs = {"userlist": [{"name": "jess, joseph i"}],
		  "window": {"start": "08/05/2014 05:00", "end": "08/05/2014 20:00"}}

# inputs = {"userlist": [{"name": "mcgreevy, sarah"}],
# 		  "window": {"start": "08/06/2014 07:00", "end": "08/06/2014 17:00"}}

# inputs = {"userlist": [{"name": "grimm, michael j"}],
# 		  "window": {"start": "08/31/2014 05:00", "end": "09/01/2014 23:00"}}

# inputs = {"userlist": [{"name": "mcgrath, d kevin"}],
# 		  "window": {"start": "08/07/2014 07:00", "end": "08/07/2014 17:00"}}


def main():
	
	s = Scheduler()

	# validUsers = s.validUsers
	# if validUsers == -1:
	# 	print s.error
	# 	sys.exit(1)
	# for user in validUsers:
	# 	print user

	if s.params(inputs) == -1:
		print s.error
		sys.exit(1)
	
	if s.schedule() == -1:
		print s.error
		sys.exit(1)

	print "times:"
	for t in s.times:

		print t[0],
		print " - ",
		print t[1]

	print "attendees"
	for a in s.attendees:
		print a
	print

	print "Window:"

	print s.paramStartWindow,
	print " - ",
	print s.paramEndWindow

	print "Events within window:"
	for e in s.allEvents:
		if e[0] > s.paramStartWindow and e[1] < s.paramEndWindow:
			print e[0],
			print " - ",
			print e[1],
			print " ",
			print e[2]
	print
	print s.solution

if __name__ == "__main__":
	main()